<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="https://unpkg.com/vue@next"></script>
    <div id="app">
        <!-- 事件名会始终转换为小写 -->
        <!-- property属性会根据分隔符进行处理，分隔符后的首字母大写-->
        <!-- property属性如果没有分隔符，会和事件名一样都转换成小写-->
        <todo-item @myEvent="parentEvent" :cur-sex="'male'" :curAge="18"></todo-item>
        <todo-item @my-event="parentEvent2"></todo-item>
    </div>

    <script>
        const vueOpt = {
            data(){
                return {

                }
            },

            methods: {
                parentEvent(){
                    console.log('---- click Me');
                },

                parentEvent2(){
                    console.log('---- click Me2');
                }
            }
        }

        const app = Vue.createApp(vueOpt);

        app.component('todo-item', {
            data(){
                return {

                }
            },
            methods:{
                clickEvent(){
                    console.log('----0');
                    this.$emit('myevent');
                },
                clickEvent2(){
                    this.$emit('my-event');
                }
            },
            props:['curSex', 'curage'],
            template: 
            `
                <div>
                    <button type="button" @click="clickEvent">clickMe</button>
                    <div>{{curSex}}</div>
                    <div>{{curage}}</div>
                    <button type="button" @click="clickEvent2">clickMe</button>
                </div>
            `
        });

        app.mount('#app');
    </script>
</body>
</html>